#===============================================================================
class PluginMount(type):
    """

    example usage

    class ValidationProvider:
        __metaclass__ = PluginMount
    """

    def __init__(cls, name, bases, attrs):
        if not hasattr(cls, 'plugins'):
            # This branch only executes when processing the mount point itself.
            # So, since this is a new plugin type, not an implementation, this
            # class shouldn't be registered as a plugin. Instead, it sets up a
            # list where plugins can be registered later.
            cls.plugins = []
        else:
            # This must be a plugin implementation, which should be registered.
            # Simply appending it to the list is all that's needed to keep
            # track of it later.
            cls.plugins.append(cls)

    
    
#-------------------------------------------------------------------------------
def test():
    
    class FooBase(object):
        __metaclass__ = PluginMount
    

    class BazBase(object):
        __metaclass__ = PluginMount


    class FooA(FooBase):
        pass
        
    class FooB(FooBase):
        pass
        
    class BazA(BazBase):
        pass
        
    class BazB(BazBase):
        pass
        
        
    for base in (FooBase, BazBase):
        print base.__name__
        for cls in base.plugins:
            print '---', cls.__name__


################################################################################
if __name__ == '__main__':
    test()